/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function(nums) {
    if(nums.length <= 1){
        return nums.length;
    }
    let k = 0;
    for (let i = k+1; i < nums.length; i++) {
        if(nums[k] !== nums[i]){
            k++;
            nums[k] = nums[i]
        }
    }
    return k+1;

};
